#include <boost/regex.hpp>
#include <iostream>
int main()
{
	std::string s = "David Hilbert";
	boost::regex expr("(\\w+)\\s(\\w+)");
	std::string fmt("\\2 \\1");
	std::cout << boost::regex_replace(s, expr, fmt) << std::endl; //*David_Hilbert
	std::cout << "original string: " << s << std::endl;           //*David Hilbert
}